n = int(input())
board = []
for _ in range(n):
    board.append(list(map(int, input().split())))
m = n // 2
board.sort(key=lambda x: x[1] - x[0])
result = 0
for i in range(n):
    if i < m:
        result += board[i][0]
    else:
        result += board[i][1]
print(result)
